package com.neusoft.springdemo.serviice.impl;

import java.util.List;

import com.neusoft.springdemo.bean.Food;
import com.neusoft.springdemo.common.ElmException;
import com.neusoft.springdemo.mapper.FoodMapper;
import com.neusoft.springdemo.serviice.FoodService;

/**
 * 
 * @author chens
 *
 */
public class FoodServiceImpl implements FoodService {

	private FoodMapper foodMapper;

	public void setFoodMapper(FoodMapper foodMapper) {
		this.foodMapper = foodMapper;
		System.out.println("=========  setFoodMapper(FoodMapper foodMapper)  ==============");
	}

	public FoodServiceImpl() {
		// 在没有使用spring前，需要编码管理FoodServiceImpl和FoodMapperJdbcImpl的关系
		// foodMapper = new FoodMapperJdbcImpl();
		System.out.println("=========  FoodServiceImpl()  ==============");
	}

	@Override
	public List<Food> getList() {
		return foodMapper.getList();
	}

	@Override
	public boolean add(Food food) throws ElmException {

		return foodMapper.add(food);

	}

	@Override
	public boolean edit(Food food) throws ElmException {
	
		return foodMapper.edit(food);
	}

	@Override
	public boolean delete(Food food) throws ElmException {
		
		return foodMapper.delete(food);
	}

}
